package m1.clientserver;

import m1.client.Client;
import m1.rpc.RPC;
import m1.server.Server;
import m2.configuration.Configuration;
import m2.connector.iface.RoleFrom;
import m2.connector.iface.RoleTo;
import m2.link.Attachment;
import m2.link.AttachmentFrom;
import m2.link.AttachmentTo;

public class ClientServer extends Configuration {

	private Client client;
	private Server server;
	private RPC rpc;

	public ClientServer(String name) {
		super(name);
		client = new Client("Client");
		rpc = new RPC("RPC");
		server = new Server("Server");
		
		addComponent(client);
		addConnector(rpc);
		addComponent(server);
		
		
		
		Attachment clientToRpc = new AttachmentTo("ClientToRpc", 
				client.getInterface("InterfaceSendRequest").getInterfaceRequis("SendRequest"), 
				(RoleTo) rpc.getRole("Caller"));
		
		addAttachmentTo((AttachmentTo) clientToRpc, 
				client.getInterface("InterfaceSendRequest").getInterfaceRequis("SendRequest"),
				(RoleTo) rpc.getRole("Caller"));
		
		Attachment rpcToServer = new AttachmentFrom("RpcToServer", 
				server.getInterface("InterfaceReceiveRequest").getInterfaceFourni("ReceiveRequestComponent"), 
				(RoleFrom) rpc.getRole("Callee"));
		
		addAttachmentFrom((AttachmentFrom) rpcToServer, 
				server.getInterface("InterfaceReceiveRequest").getInterfaceFourni("ReceiveRequestComponent"), 
				(RoleFrom) rpc.getRole("Callee"));
	}

	
	
	
	
	
}
